package com.durian.finance.service.impl;

import com.durian.common.core.utils.DateUtils;
import com.durian.finance.mapper.CfContractMapper;
import com.durian.finance.service.ICfContractService;
import com.durian.financial.api.domain.CfContract;
import com.durian.financial.api.domain.vo.ContractVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 租房合同Service业务层处理
 * 
 * @author durian
 * @date 2022-06-27
 */
@Service
public class CfContractServiceImpl implements ICfContractService 
{
    @Autowired
    private CfContractMapper cfContractMapper;

    /**
     * 查询租房合同
     * 
     * @param id 租房合同主键
     * @return 租房合同
     */
    @Override
    public CfContract selectCfContractById(Long id)
    {
        return cfContractMapper.selectCfContractById(id);
    }

    /**
     * 查询租房合同列表
     * 
     * @param cfContract 租房合同
     * @return 租房合同
     */
    @Override
    public List<CfContract> selectCfContractList(CfContract cfContract)
    {
        return cfContractMapper.selectCfContractList(cfContract);
    }

    /**
     * 新增租房合同
     * 
     * @param cfContract 租房合同
     * @return 结果
     */
    @Override
    public int insertCfContract(CfContract cfContract)
    {
        cfContract.setCreateTime(DateUtils.getNowDate());
        return cfContractMapper.insertCfContract(cfContract);
    }

    /**
     * 修改租房合同
     * 
     * @param cfContract 租房合同
     * @return 结果
     */
    @Override
    public int updateCfContract(CfContract cfContract)
    {
        cfContract.setUpdateTime(DateUtils.getNowDate());
        return cfContractMapper.updateCfContract(cfContract);
    }

    /**
     * 批量删除租房合同
     * 
     * @param ids 需要删除的租房合同主键
     * @return 结果
     */
    @Override
    public int deleteCfContractByIds(Long[] ids)
    {
        return cfContractMapper.deleteCfContractByIds(ids);
    }

    /**
     * 删除租房合同信息
     * 
     * @param id 租房合同主键
     * @return 结果
     */
    @Override
    public int deleteCfContractById(Long id)
    {
        return cfContractMapper.deleteCfContractById(id);
    }

    /**
     * 获取符合保理申请明细的租房合同列表
     *
     * @param vo
     * @return
     */
    @Override
    public List<CfContract> listFactoringContract(ContractVO vo) {
        return cfContractMapper.listFactoringContract(vo);
    }
}
